package com.qf.service.impl;
/*
   @author 86155
   @ClassName: com.qf.service.impl.BannerServiceImpl
   @Description: 该类的功能描述
   @date: 2021/9/29 19:04 
*/

import com.github.pagehelper.PageHelper;
import com.qf.entity.Banner;
import com.qf.mapper.BannerMapper;
import com.qf.request.RequestParams;
import com.qf.service.BannerService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BannerServiceImpl implements BannerService {
    @Resource
    private BannerMapper bannerMapper;

    @Override
    public int addBanner(RequestParams requestParams) {
        Banner banner = new Banner();
        BeanUtils.copyProperties(requestParams,banner);
        return bannerMapper.insertBanner(banner);
    }

    @Override
    public Integer updateBanner(RequestParams requestParams) {
        Banner banner = new Banner();
        BeanUtils.copyProperties(requestParams,banner);
        return bannerMapper.updateBanner(banner);
    }

    @Override
    public Integer deleteBanner(Long bid) {
        return bannerMapper.deleteBanner(bid);
    }

    @Override
    public List<Banner> selectAllBanner(String bannerName, Integer page, Integer size) {
        PageHelper.startPage(page, size);
        return bannerMapper.selectAllBanner(bannerName);
    }
}
